﻿function loadMenu(pos1, pos2, type) {
    var menu = '';
    menu += '<a name="menuType" href="/Movie/Index.aspx" class="" onmouseover="activeMenu(this); loadSubmenu(0' + ',' + pos2 + ',' + type + ');">Trang chủ</a>';
    menu += '<a name="menuType" href="/Movie/lich-chieu-tivi.html" class="" onmouseover="activeMenu(this); loadSubmenu(1' + ',' + pos2 + ',' + type + ');">Lịch chiếu phim</a>';
    menu += '<a name="menuType" href="/Movie/xem-tivi-online.html" class="" onmouseover="activeMenu(this); clearSubMenu();">Tivi online</a>';
    menu += '<a name="menuType" href="/Movie/tro-choi-dien-anh.html" class="" onmouseover="activeMenu(this); clearSubMenu();">Trò chơi ĐA</a>';
    menu += '<a name="menuType" href="/Movie/cam-nhan.html" class="" onmouseover="activeMenu(this); clearSubMenu();">Cảm nhận phim</a>';
    //menu += '<a name="menuType" href="/Movie/galaxy-cinema.html" class="" onmouseover="activeMenu(this); clearSubMenu();">Galaxy</a>';
    menu += '<a name="menuType" href="http://tdbe.mp3.zing.vn/" target="_blank" class="" onmouseover="activeMenu(this); clearSubMenu();">Tuyển diễn viên</a>';
    menu += '<a name="menuType" href="http://brrrr.movie.zing.vn/" target="_blank" class="" onmouseover="activeMenu(this); clearSubMenu();">Brrrr</a>';
    document.getElementById('mainmenu').innerHTML = menu;
    var arrType = document.getElementsByName('menuType');
    arrType[pos1].className = 'curnav';
    loadSubmenu(pos1, pos2, type);
}
function loadSubmenu(pos1, pos2, type) {
    var menu = '';
    switch (pos1) {
        case 0:
            menu += '<a name="submenuType" class="" href="/Movie/phim-noi-bat.html">Phim nổi bật</a>';
            menu += '<a name="submenuType" class="" href="/Movie/phim-bo-moi-nhat.html">Phim bộ mới nhất</a>';
            menu += '<a name="submenuType" class="" href="/Movie/phim-dien-anh-moi-nhat.html">Phim điện ảnh mới nhất</a>';
            menu += '<a name="submenuType" class="" href="/Movie/phim-xem-nhieu-nhat.html">Phim xem nhiều nhất</a>';
            menu += '<a name="submenuType" class="" href="/Movie/phim-de-cu.html">Phim đề cử</a>';
            menu += '<a name="submenuType" class="" href="/Movie/phim-oscar.html">Tuyển tập Michael Jackson</a>';
            break;
        case 1:
            menu += '<a name="submenuType" class="" href="/Movie/lich-chieu-tivi.html">Lịch chiếu tivi</a>';
            menu += '<a name="submenuType" class="" href="/Movie/lich-chieu-rap.html">Lịch chiếu rạp</a>';
            menu += '<a name="submenuType" class="" href="/Movie/phim-sap-chieu-rap.html">Phim sắp chiếu rạp</a>';
            break;
    }
    document.getElementById('submenu').className = 'submenu';
    document.getElementById('submenu').innerHTML = menu;
    if (type == pos1) {
        var arrType = document.getElementsByName('submenuType');
        arrType[pos2].className = 'curnav';
    }
}
function clearSubMenu() {
    document.getElementById('submenu').innerHTML = '';
}
function activeMenu(obj) {
    var arrType = document.getElementsByName('menuType');
    for (var i = 0; i < arrType.length; i++) {
        arrType[i].className = '';
    }
    obj.className = 'curnav';
}
function applyType(obj, value) {
    var arrType = document.getElementsByName('searchType');
    for (var i = 0; i < arrType.length; i++) {
        arrType[i].className = '';
    }
    obj.className = 'curnav';
    $('t').value = value;
}
//Open popup
function openWindow(filename, winname, width, height, feature) {
    var features, top, left;
    var reOpera = /opera/i;
    var winnameRequired = ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) || reOpera.test(navigator.userAgent));

    left = (window.screen.width - width) / 2;
    top = (window.screen.height - height) / 2;
    if (feature == '')
        features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",status=0,location=0";
    else
        features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + "," + feature;
    //	if(!winnameRequired)	winname = "";
    newwindow = window.open(filename, winname, features);
    newwindow.focus();
}
function SubmitVote(type) {
    if (type == 1) {
        answers = document.getElementsByName('surveyresponse');
        id = -1;
        for (var i = 0; i < answers.length; i++) {
            if (answers[i].checked) {
                id = answers[i].value;
                break;
            }
        }
        if (id == -1) {
            alert("Hãy chọn một trong các mục trước khi bình chọn.");
        }
        else {
            var x = readCookie('zingmovievote')
            if (x) {
                alert("Bạn chỉ được bình chọn 1 lần ^^");
            }
            else {
                //createCookie("zingmovievote", "zmovie", 1);
                openWindow("/Movie/SurveyResult.aspx?t=1&a=" + id, "", 600, 300, "");
            }
        }
    }
    else
        openWindow("/Movie/SurveyResult.aspx?t=0", "", 600, 300, "");
    return false;
}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function logout() {
    if (confirm('Bạn thực sự muốn thoát?')) {
        //window.location.href = '/Movie/login/Logout.aspx';
		window.location.href = 'http://sso2.zing.vn/?method=logout&return=http://movie.zing.vn/';
    } else {
        return;
    }
}
		